package com.example.redisdemo;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

// 7、创造伪造客户端
public class Hack {
    public static void main(String[] args) throws IOException {
        // 创建端口号6379服务端
        ServerSocket serverSocket = new ServerSocket(6379);
        // 获得imputStream流
        Socket socket = serverSocket.accept();
        // 转存
        InputStream inputStream = socket.getInputStream();
        // 字符串转为byte数组
        byte b[] = new byte[1024];
        // 从输入流中读取字节
        inputStream.read(b);
        // 转为String类型并输出
        System.out.println(new String(b));

    }
//    cmd - telnet localhost 6379 - 回车
}
